package com.example.qxfw.dzzh.controller;

import com.example.qxfw.common.SysResult;
import com.example.qxfw.dzzh.service.DZYjcsService;
import com.example.qxfw.shfx.entity.YjfxshYzdisppara;
import com.example.qxfw.shfx.entity.YjfxshYzdispparaRad;
import com.example.qxfw.shfx.vo.YjcsJsxwx;
import com.example.qxfw.shfx.vo.YjcsVoxwx;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: xwx
 * @description: 地质灾害的参数显示
 * @date: 2024/4/30
 * @version: 1.0
 */
@Api(tags = "地质灾害--预警参数设置")
@RestController
@RequestMapping("/DZzhCSController")
public class DzzhCSController {
    @Resource
    private DZYjcsService yjcsService;

    @ApiOperation("地质灾害--预警参数-短期预警--设置参数(添加)")
    @PostMapping("/settingParametersInsertDQ")
    public SysResult settingParametersInsertDQ(double value, int color){
        YjfxshYzdisppara result = yjcsService.settingParametersInsert(value, color);
        if (result != null) {
            return SysResult.success(result);
        }else {
            return SysResult.fail("添加数据失败！！！");
        }
    }

    @ApiOperation("地质灾害--预警参数-短期预警--设置参数(修改)")
    @PutMapping("/settingParametersUpdateDQ")
    public SysResult settingParametersUpdateDQ(@RequestBody YjfxshYzdisppara yjfxshYzdisppara){
        YjfxshYzdisppara result = yjcsService.settingParametersUpdate(yjfxshYzdisppara);
        if (result != null) {
            return SysResult.success(result);
        }else {
            return SysResult.fail("更新数据失败！！！");
        }
    }

    @ApiOperation("地质灾害--预警参数短期预警--设置参数(删除)")
    @DeleteMapping("/settingParametersDeleteDQ")
    public SysResult settingParametersDeleteDQ(int id){
        int result = yjcsService.settingParametersDelete(id);
        return SysResult.success(result);
    }

    @ApiOperation("地质灾害--预警参数-短期预警--设置参数(查询)")
    @GetMapping("/settingParameterSelectDQ")
    public SysResult settingParameterSelectDQ(){
        List<YjfxshYzdisppara> result = yjcsService.settingParameterSelect();
        return SysResult.success(result);
    }

    @ApiOperation("地质灾害--预警参数-短期预警--修改影响值")
    @PutMapping("/savedqybpara")
    public SysResult savedqybpara(@RequestBody YjcsJsxwx yjcsJsxwx){
        String result = yjcsService.savedqybpara(yjcsJsxwx);
        return SysResult.success(result);
    }
    //修改的地方，增加了一个显示参数的接口
    @ApiOperation("地质灾害--预警参数-短期预警--参数显示")
    @PostMapping("/settingParametersInsertLT1")
    public SysResult settingParametersInsertLT1() {
        YjcsVoxwx yjcsVoxwx = yjcsService.settingParametersInsertLT1();
        return SysResult.success(yjcsVoxwx);
    }

//------------------------------------------------------------------------------------------------------------------------------

    @ApiOperation("地质灾害--预警参数-短临预警--设置参数(添加)")
    @PostMapping("/settingParametersInsertDL")
    public SysResult settingParametersInsertDL(double value, int color){
        YjfxshYzdispparaRad result = yjcsService.settingParametersInsertDL(value, color);
        if (result != null) {
            return SysResult.success(result);
        }else {
            return SysResult.fail("添加数据失败！！！");
        }
    }
    @ApiOperation("地质灾害--预警参数-短临预警--设置参数(修改)")
    @PutMapping("/settingParametersUpdateDL")
    public SysResult settingParametersUpdateDL(@RequestBody YjfxshYzdispparaRad yjfxshYzdispparaRad){
        YjfxshYzdispparaRad result = yjcsService.settingParametersUpdateDL(yjfxshYzdispparaRad);
        if (result != null) {
            return SysResult.success(result);
        }else {
            return SysResult.fail("更新数据失败！！！");
        }
    }

    @ApiOperation("地质灾害--预警参数-短临预警--设置参数(删除)")
    @DeleteMapping("/settingParametersDeleteDL")
    public SysResult settingParametersDeleteDL(int id){
        int result = yjcsService.settingParametersDeleteDL(id);
        return SysResult.success(result);
    }

    @ApiOperation("地质灾害--预警参数-短临预警--设置参数(查询)")
    @GetMapping("/settingParameterSelectDL")
    public SysResult settingParameterSelectDL(){
        List<YjfxshYzdispparaRad> result = yjcsService.settingParameterSelectDL();
        return SysResult.success(result);
    }
    @ApiOperation("地质灾害--预警参数-短临预警--修改影响值")
    @PutMapping("/savedqybparaRd")
    public SysResult savedqybparaRd(@RequestBody YjcsJsxwx yjcsJsxwx){
        String result = yjcsService.savedqybparaRd(yjcsJsxwx);
        return SysResult.success(result);
    }
    //修改的地方，增加了一个显示参数的接口
    @ApiOperation("地质灾害--预警参数-短临预警--参数显示")
    @PostMapping("/settingParametersInsertLT")
    public SysResult settingParametersInsertLT(){
        YjcsVoxwx yjcsVoxwx = yjcsService.settingParametersInsertLT();
        return SysResult.success(yjcsVoxwx);
    }
}
